<?php
include("../../product/model.php");
include("../../image/model.php");

$body_html = "";

if (validate_image($_FILES['image']) == false)
{
	$_POST["big_image"] = $_POST["old_image"];
	$_POST["small_image"] = $_POST["old_image"];
}
else
{
	$image = upload_image($_FILES['image'], "../../upload/");
	if ($image == NULL)
	{
		$body_html = "上传图片失败!";
		return;
	}

	$_POST["big_image"] = $image["big_image"];
	$_POST["small_image"] = $image["small_image"];
}

// 如果需要上传图片
if (model_update_product($_POST["id"], $_POST) == true)
{
	$body_html = "更新成功！";
}
else
{
	$body_html = "更新失败！";
}

include("../template/layout.php");
?>
